package com.enlorenz.common.geo.map.base;

import java.util.List;

import com.enlorenz.common.geo.base.IPoint;
import com.enlorenz.common.geo.map.callback.IDownloadResultCallback;
import com.enlorenz.common.geo.map.callback.IProgressCallback;
import com.enlorenz.common.geo.map.callback.ITileMsgDisplayCallback;

/**
 * 地图配置
 * @author Karma
 */
public class MapConfig {
	//范围点集合
	private List<IPoint> pointList;
	//地图级别
	private int [] zoom;
	//线程数目
	private Integer threadNum;
	//输入目录
	private String srcFilePath;
	//输出目录
	private String dstFilePath;
	//核心类路径
	private String coreClass;
	//模板Url
	private String templateUrl;
	//下载失败图片的重试次数
	private int picTryTimes=3;
	//是否显示url
	private boolean displayUrl;
	//是否覆盖
	private boolean cover=false;
	//步进
	private String step;
	

	public boolean isCover() {
		return cover;
	}
	public void setCover(boolean cover) {
		this.cover = cover;
	}
	public String getStep() {
		return step;
	}
	public void setStep(String step) {
		this.step = step;
	}
	public boolean isDisplayUrl() {
		return displayUrl;
	}
	public void setDisplayUrl(boolean displayUrl) {
		this.displayUrl = displayUrl;
	}
	public int getPicTryTimes() {
		return picTryTimes;
	}
	public void setPicTryTimes(int picTryTimes) {
		this.picTryTimes = picTryTimes;
	}
	public String getTemplateUrl() {
		return templateUrl;
	}
	public void setTemplateUrl(String templateUrl) {
		this.templateUrl = templateUrl;
	}
	public String getCoreClass() {
		return coreClass;
	}
	public void setCoreClass(String coreClass) {
		this.coreClass = coreClass;
	}
	//瓦片处理消息显示
	private ITileMsgDisplayCallback tileMsgDisplay;
	//进度回调函数
	private IProgressCallback progressCallBack;
	//下载消息回调函数
	private IDownloadResultCallback downloadResultCallback;
	
	public static String getTypeDesc(int type){
		if(type == IDownloadResultCallback.RESULT_TYPE_SUCCESS_DOWNLOAD){
			return "切片成功";
		}else if(type == IDownloadResultCallback.RESULT_TYPE_SUCCESS_EXISTS){
			return "文件已存在";
		}else if(type == IDownloadResultCallback.RESULT_TYPE_FAILED_WRITE_FILE){
			return "写文件失败";
		}else if(type == IDownloadResultCallback.RESULT_TYPE_FAILED_DOWNLOAD){
			return "切片失败";
		}else if(type == IDownloadResultCallback.RESULT_TYPE_FAILED_NOT_IN＿AREA){
			return "超出范围";
		}
		return "";
	}
	
	/**
	 * 下载结果显示
	 * @param threadName	线程名
	 * @param 类型	处理类型
	 * @param msg	描述
	 * @param index	当前进度
	 * @param total	总进度
	 * @param googleTileWrapper	具体瓦片信息
	 * @param url	请求的url信息
	 * @param costTime 处理时长
	 */
	public void downloadResult(String threadName,int type,String msg,int index,long total,TileWrapper googleTileWrapper,String url
			,long costTime){
		if(null!=getDownloadResultCallback()){
			getDownloadResultCallback().
			downloadResult(threadName,type, msg, index, total, googleTileWrapper, url,costTime);
		}
	}
	/**
	 * 显示进度
	 * @param index	当前进度
	 * @param total	总进度
	 */
	public void progress(int allCount,long totalNum){
		if(null!=getProgressCallBack()){
			getProgressCallBack().progress(allCount, totalNum);
		}
	}
	/**
	 * 显示消息
	 * @param msg	信息
	 */
	public void display(String msg){
		if(null!=getTileMsgDisplay()){
			getTileMsgDisplay().display(msg);
		}
	}
	
	
	
	public List<IPoint> getPointList() {
		return pointList;
	}
	public void setPointList(List<IPoint> pointList) {
		this.pointList = pointList;
	}
	public int [] getZoom() {
		return zoom;
	}
	public void setZoom(int [] zoom) {
		this.zoom = zoom;
	}
	public Integer getThreadNum() {
		return threadNum;
	}
	public void setThreadNum(Integer threadNum) {
		this.threadNum = threadNum;
	}
	public String getSrcFilePath() {
		return srcFilePath;
	}
	public void setSrcFilePath(String srcFilePath) {
		this.srcFilePath = srcFilePath;
	}
	public String getDstFilePath() {
		return dstFilePath;
	}
	public void setDstFilePath(String dstFilePath) {
		this.dstFilePath = dstFilePath;
	}
	public ITileMsgDisplayCallback getTileMsgDisplay() {
		return tileMsgDisplay;
	}
	public void setTileMsgDisplay(ITileMsgDisplayCallback tileMsgDisplay) {
		this.tileMsgDisplay = tileMsgDisplay;
	}
	public IProgressCallback getProgressCallBack() {
		return progressCallBack;
	}
	public void setProgressCallBack(IProgressCallback progressCallBack) {
		this.progressCallBack = progressCallBack;
	}
	public IDownloadResultCallback getDownloadResultCallback() {
		return downloadResultCallback;
	}
	public void setDownloadResultCallback(
			IDownloadResultCallback downloadResultCallback) {
		this.downloadResultCallback = downloadResultCallback;
	}
}
